from manimlib import *

sys.path.append('.')
from customized import *


class p1(Scene):
    def construct(self):
        # self.camera.frame.save_state()
        # self.add(NumberPlane())
        # self.camera.frame.rotate(13*DEGREES,about_point=[0.0, 0.0, 1.0])
        t1 = Triangle().scale(1.5).shift(DOWN * 0.7).set_color(LV)
        t2 = Triangle().scale(2.6).shift(DOWN * 0.65).set_color(LV)
        t3 = Triangle().scale(4.2).set_color(LV)
        self.add(t1, t2, t3,
                 t1.copy().rotate_about_origin(PI),
                 t2.copy().rotate_about_origin(PI),
                 t3.copy().rotate(PI),
                 )
        self.wait()


class p2(Scene):
    def construct(self):
        # self.camera.frame.save_state()
        # self.add(NumberPlane())
        # self.camera.frame.rotate(13*DEGREES,about_point=[0.0, 0.0, 1.0])
        t1 = Triangle().scale(1.5).shift(DOWN * 0.7).set_color(LV)
        t2 = Triangle().scale(2.6).shift(DOWN * 0.65).set_color(LV)
        t3 = Triangle().scale(4.2).set_color(LV)
        self.add(t1, t2, t3,
                 t1.copy().rotate_about_origin(PI),
                 t2.copy().rotate_about_origin(PI),
                 t3.copy().rotate(PI),
                 )
        self.add(
            CustomizedTex('1').set_color(LV).next_to(t3, DL),
            CustomizedTex('2').set_color(LV).next_to(t2, DL),
            CustomizedTex('3').set_color(LV).next_to(t1, DL),
            CustomizedTex('4').set_color(LV).move_to([-3.5, 2.5, 0]),
            CustomizedTex('5').move_to([-1, -2, 0]),
            CustomizedTex('6').move_to([0, -2, 0]),
            CustomizedTex('7').move_to([[1, -2, 0]]),
            CustomizedTex('8').move_to([-1, -1.4, 0]),
            CustomizedTex('9').move_to([1, -1.4, 0]),
            CustomizedTex('10').move_to([0, -2.5, 0]),
            CustomizedTex('11').move_to([-2, 3, 0]),
            CustomizedTex('12').move_to([2, 3, 0]),
            CustomizedTex('13').move_to([-2, -2.6, 0]),
            CustomizedTex('14').move_to([2, -2.6, 0]),
            CustomizedTex('15').set_color(LV).move_to([-2, 2.5, 0]),
            CustomizedTex('16').move_to([-0.6, -1, 0]),
            CustomizedTex('17').move_to([0.6, -1, 0]),
            CustomizedTex('18').move_to([-1.5, 2, 0]),
            CustomizedTex('19').move_to([1.5, 2, 0]),
            CustomizedTex('20').move_to([0, 2.8, 0]),
            CustomizedTex('21').set_color(LV).move_to([0, -0.8, 0]),
            CustomizedTex('22').move_to([-0.7, 1, 0]),
            CustomizedTex('23').move_to([0.7, 1, 0]),
            CustomizedTex('24').move_to([-1.5, 1.5, 0]),
            CustomizedTex('25').move_to([1.5, 1.5, 0]),
            CustomizedTex('26').move_to([0, 2, 0])
        )
        self.wait()


class p3(Scene):
    def construct(self):
        # self.camera.frame.save_state()
        # self.add(NumberPlane())
        # self.camera.frame.rotate(13*DEGREES,about_point=[0.0, 0.0, 1.0])
        side_length = 1.9
        high = side_length / 2 * np.sqrt(3)
        l = Line(LEFT * side_length / 2, RIGHT * side_length / 2).set_color(LV)
        l1 = l.copy().shift(UP * 1.5 * high + DOWN * 0.5)
        l2 = l.copy().scale(2).shift(UP * 0.5 * high + DOWN * 0.5)
        l3 = l.copy().scale(3).shift(DOWN * 0.5 * high + DOWN * 0.5)
        l4 = l.copy().scale(4).shift(DOWN * 1.5 * high + DOWN * 0.5)
        # self.add(l1,l2,l3,l4)
        for i in [l1, l2, l3, l4]:
            for j in range(3):
                self.add(i.copy().rotate(PI / 3 * 2 * (j + 1), about_point=DOWN * 0.78))
        self.wait()


class p11(Scene):
    def construct(self):
        # self.camera.frame.save_state()
        # self.add(NumberPlane())
        # self.camera.frame.rotate(13*DEGREES,about_point=[0.0, 0.0, 1.0])
        t1 = Triangle().scale(1.5).shift(DOWN * 0.7).set_color(LV)
        t2 = Triangle().scale(2.6).shift(DOWN * 0.65).set_color(LV)
        t3 = Triangle().scale(4.2).set_color(LV)
        self.add(t1, t2, t3,
                 )
        self.add(
            CustomizedTex('1').set_color(LV).next_to(t3, DL),
            CustomizedTex('2').set_color(LV).next_to(t2, DL),
            CustomizedTex('3').set_color(LV).next_to(t1, DL),
        )
        self.wait()


class p12(Scene):
    def construct(self):
        # self.camera.frame.save_state()
        # self.add(NumberPlane())
        # self.camera.frame.rotate(13*DEGREES,about_point=[0.0, 0.0, 1.0])
        t1 = Triangle().scale(1.5).shift(DOWN * 0.7).set_color(LV)
        t2 = Triangle().scale(2.6).shift(DOWN * 0.65).set_color(LV)
        t3 = Triangle().scale(4.2).set_color(LV)
        self.add(t1, t2, t3,
                 t3.copy().rotate(PI),
                 )
        self.add(
            CustomizedTex('1').set_color(LV).next_to(t3, DL),
            CustomizedTex('2').set_color(LV).next_to(t2, DL),
            CustomizedTex('3').set_color(LV).next_to(t1, DL),
            CustomizedTex('4').set_color(LV).move_to([-3.5, 2.5, 0]),
            CustomizedTex('5').move_to([-1, -2, 0]),
            CustomizedTex('6').move_to([0, -2, 0]),
            CustomizedTex('7').move_to([[1, -2, 0]]),
            CustomizedTex('8').move_to([-1, -1.4, 0]),
            CustomizedTex('9').move_to([1, -1.4, 0]),
            CustomizedTex('10').move_to([0, -2.5, 0]),
            CustomizedTex('11').move_to([-2, 3, 0]),
            CustomizedTex('12').move_to([2, 3, 0]),
            CustomizedTex('13').move_to([-2, -2.6, 0]),
            CustomizedTex('14').move_to([2, -2.6, 0]),
        )
        self.wait()


class p13(Scene):
    def construct(self):
        # self.camera.frame.save_state()
        # self.add(NumberPlane())
        # self.camera.frame.rotate(13*DEGREES,about_point=[0.0, 0.0, 1.0])
        t1 = Triangle().scale(1.5).shift(DOWN * 0.7).set_color(LV)
        t2 = Triangle().scale(2.6).shift(DOWN * 0.65).set_color(LV)
        t3 = Triangle().scale(4.2).set_color(LV)
        self.add(t1, t2, t3,
                 t2.copy().rotate_about_origin(PI),
                 t3.copy().rotate(PI),
                 )
        self.add(
            CustomizedTex('1').set_color(LV).next_to(t3, DL),
            CustomizedTex('2').set_color(LV).next_to(t2, DL),
            CustomizedTex('3').set_color(LV).next_to(t1, DL),
            CustomizedTex('4').set_color(LV).move_to([-3.5, 2.5, 0]),
            CustomizedTex('5').move_to([-1, -2, 0]),
            CustomizedTex('6').move_to([0, -2, 0]),
            CustomizedTex('7').move_to([[1, -2, 0]]),
            CustomizedTex('8').move_to([-1, -1.4, 0]),
            CustomizedTex('9').move_to([1, -1.4, 0]),
            CustomizedTex('10').move_to([0, -2.5, 0]),
            CustomizedTex('11').move_to([-2, 3, 0]),
            CustomizedTex('12').move_to([2, 3, 0]),
            CustomizedTex('13').move_to([-2, -2.6, 0]),
            CustomizedTex('14').move_to([2, -2.6, 0]),
            CustomizedTex('15').set_color(LV).move_to([-2, 2.5, 0]),
            CustomizedTex('16').move_to([-0.6, -1, 0]),
            CustomizedTex('17').move_to([0.6, -1, 0]),
            CustomizedTex('18').move_to([-1.5, 2, 0]),
            CustomizedTex('19').move_to([1.5, 2, 0]),
            CustomizedTex('20').move_to([0, 2.8, 0]),
        )
        self.wait()
